<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			var arr = [5,2,3,1,4];
			
			function sort(arr){
				for(var i=0;i<arr.length;i++){
					for(var j=i+1;j<arr.length;j++){
						if(arr[i]>arr[j]){
							var temp = arr[i];
							arr[i] = arr[j];
							arr[j] = temp;
						}
					}
				}
				return arr;
			}
			
//			console.log(sort(arr));
			
			var arr = [5,2,3,1,4];
			function sort2(arr){
				
				var newArr = [];
				var length = arr.length;
				for(var i=0;i<length;i++){
					var min = arr[0];
					for(var j=0;j<arr.length;j++){
						if(min>arr[j]){
							min = arr[j];
						}
					}
					newArr.push(min);
					arr.splice(arr.indexOf(min),1);
				}
				return newArr;
			}
			
			console.log(sort2(arr));
			
			
			var arr = [1,2,3,4];
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
		</script>
	</body>
</html>
